package www.woniuxy.com.class112.controller;

import cn.hutool.core.bean.BeanUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import www.woniuxy.com.class112.entity.IssueType;
import www.woniuxy.com.class112.form.issues.SelectIssueTypeForm;
import www.woniuxy.com.class112.param.issues.SelectIssueTypeParam;
import www.woniuxy.com.class112.service.IssueTypeService;
import www.woniuxy.com.class112.util.Result;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/issueType")
@Api(tags = "问题类别选项表")
public class IssueTypeController {

    @Resource
    private IssueTypeService issueTypeService;
    @GetMapping("/queryQuestionCategory")
    @ApiOperation("查询问题类别")
    public Result queryQuestionCategory(){
        List<IssueType> issueType = issueTypeService.queryQuestionCategory();
        return Result.success("查询成功",issueType);
    }
    @PostMapping("queryQuestionCategoryByname")
    @ApiOperation("根据名字查询问题类别")
    public Result queryQuestionCategoryByname(@RequestBody SelectIssueTypeForm form)throws Exception{
        return Result.success("查询成功",issueTypeService.queryQuestionCategoryByname(BeanUtil.toBean(form, SelectIssueTypeParam.class)));
    }
    @GetMapping("/addIssueType")
    @ApiOperation("添加问题类别")
    public Result addIssueType(String issueName){
        issueTypeService.addIssueType(issueName);
        return Result.success("添加成功",null);
    }
}
